<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<script type="text/javascript">
	function courierDelete(id){
		if(confirm("确定要删除这条记录吗?")){
			$.post("${pageContext.request.contextPath}/courier/delete.do",{id:id},
				function(result){
					var result=eval('('+result+')');
					if(result.errorInfo){
						alert(result.errorInfo);
					}else{
						alert("删除成功");
						window.location.href="${pageContext.request.contextPath}/courier/list.do";
					}
				}
			);
		}
	}
</script>
<div class="row search" >
	<form action="${pageContext.request.contextPath}/courier/list.do" method="post">
		<div class="col-md-4">
		      <input type="text" class="form-control" name="name"  value="${s_courier.name }" placeholder="快递员姓名查询">
	    </div>
	    <div class="col-md-4">
	    	<input type="text" class="form-control" name="address"  value="${s_courier.address }" placeholder="地址查询">
	    </div>
	    <div class="col-md-2">
		      <span class="input-group-btn">
		        <button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search"></span>&nbsp;查询</button>
		      </span>
		 </div>
		 <div class="col-md-2" >
		 	<c:if test="${currentUser.roleName=='管理员' }">
		  	<button type="button" class="btn btn-primary" style="float: right;" onclick="javascript:window.location.href='${pageContext.request.contextPath}/courier/preSave.do'">添加</button>
		 	</c:if>
		 </div>
	</form>
 <%--  <div class="col-md-10">
	<form action="${pageContext.request.contextPath}/courier/list.do" method="post">
	    <div class="col-md-5">
		      <input type="text" class="form-control" name="name"  value="${s_courier.name }" placeholder="快递员姓名查询">
	    </div>
	    <div class="col-md-5">
	    	<input type="text" class="form-control" name="address"  value="${s_courier.address }" placeholder="地址查询">
	    </div>
	    <div class="col-md-2">
		      <span class="input-group-btn">
		        <button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search"></span>&nbsp;查询</button>
		      </span>
		 </div>
    </form>
  </div>
  <div class="col-md-2" >
  	<button type="button" class="btn btn-primary" style="float: right;" onclick="javascript:window.location.href='${pageContext.request.contextPath}/courier/preSave.do'">添加</button>
  </div> --%>
</div>
<div>
	<table class="table table-hover  table-bordered table-striped" style="margin-bottom: 0px;">
	  <tr>
	  	<th>序号</th>
	  	<th>快递员</th>
	  	<th>公司</th>
	  	<th>住址</th>
	  	<th>联系电话</th>
	  	<th>邮箱</th>
	  	<c:if test="${currentUser.roleName=='管理员' }">
	  	<th>操作</th>
	  	</c:if>
	  </tr>
	  <c:forEach var="courier" items="${courierList }" varStatus="status">
	  	<tr>
	  		<td>${status.index+1 }</td>
	  		<td>${courier.name }</td>
	  		<td>${courier.companyName }</td>
	  		<td>${courier.address }</td>
	  		<td>${courier.phone }</td>
	  		<td>${courier.email }</td>
	  		<c:if test="${currentUser.roleName=='管理员' }">
	  		<td>
	  			<button type="button" class="btn btn-info btn-xs" onclick="javascript:window.location.href='${pageContext.request.contextPath}/courier/preSave.do?id=${courier.id }'">修改</button>
	  			<button type="button" class="btn btn-danger btn-xs" onclick="courierDelete(${courier.id })">删除</button>
	  		</td>
	  		</c:if>
	  	</tr>
	  </c:forEach>
	</table>
	<nav >
		<ul class="pagination">
			${pageCode }
		</ul>
	</nav>
</div>



